|
|
|
|
|
|
|
If you look at Tutorial 2, "Memory, Where It All Begins," you'll see that the only difference between a signed and an unsigned variable is the placement of the range. Signed bytes range from 128 to 127, unsigned bytes from 0 to 255. All you need to do to convert an out of range number from one to another is to subtract 256 using the following expression: |
|
|
|
|
|
|
|
|
SignedValue = UnsignedValue - 256
UnsignedValue = SignedValue + 256 |
|
|
|
|
|
|
|
|
So to set the mChar value, just add 256 to50 to obtain 206. |
|
|
|
|
|
|
|
|
Integers are handled similarly: |
|
|
|
|
|
|
|
|
SignedValue = UnsignedValue - &H10000
UnsignedValue = SignedValue + &H10000 |
|
|
|
|
|
|
|
|
Note that you'll have to use long variables to do the calculations in order to prevent overflows. The same technique works with long variables, except that you'll need to use doubles to handle the intermediate results to prevent overflows (and risk losing some precision along the way). |
|
|
|
|
|
|
|
|
Neither the Currency nor Date data types are used by Win32 API functions. Refer to the source code for the apigid32.dll project (in C++) for examples of how these parameters can be used with custom dynamic link libraries. (The apigid32.dll project can be found on the CD that comes with this book.) |
|
|
|
|
|
|
|
|
User-defined types are passed to API functions by referencemeaning that a pointer to the structure is passed as a parameter. In most cases, converting a C structure to a Visual Basic user-defined type is straightforward, but there are exceptions. An in-depth explanation of how to handle structures can be found in Tutorial 7, "Classes, Structures, and User-Defined Types." |
|
|
|
|
|